Skip to content

Conversation

cliffmccarthy
Copy link
Contributor

  • Added import-vcard and make-vcard commands to deltachat-repl. These wrap the corresponding import_vcard() and make_vcard() operations from src/contact.rs. Each command takes a file path argument specifying the location of the vCard file to be read or written. The make-vcard command takes one or more IDs to write to the file.
  • Documented commands in "Using the CLI client" section of README.md.

closes #7047

- Added import-vcard and make-vcard commands to deltachat-repl.  These
  wrap the corresponding import_vcard() and make_vcard() operations
  from src/contact.rs.  Each command takes a file path argument
  specifying the location of the vCard file to be read or written.
  The make-vcard command takes one or more IDs to write to the file.
- Documented commands in "Using the CLI client" section of README.md.

closes chatmail#7047
- In key contact example, use project terminology "key-contact".
- Removed unnecessary "to" from import-vcard output.
- Use split_whitespace() to separate IDs in make-vcard.
- All changes suggested in review by iequidoo.
@@ -1218,6 +1220,24 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
log_contactlist(&context, &contacts).await?;
println!("{} blocked contacts.", contacts.len());
}
"import-vcard" => {
ensure!(!arg1.is_empty(), "Argument <file> missing.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if we support whitespaces in arguments (but only if we want the repl tool to be really useful, not just for testing), AFAIU currently you can't import a vcard from, say, "Bob Smith.vcf". Maybe backslash escaping is enough

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, the classic filenames-with-spaces problem. This code is downstream from the logic that parses arg1 and arg2, so it would be messy to fix this without changing the whole parser strategy. (I suppose we could re-parse all of line inside the import-vcard handler, but that doesn't seem like a good path to start going down.) For the export (make-vcard), I had originally implemented this with the file as the second argument, which probably would support spaces, because of how arg2 is created, but I moved the filename to the first argument because I wanted to take advantage of the multiple contact support of make_vcard() instead of artificially limiting it to one, thus not fully exposing the interface of the underlying function. But we still would have the problem on import-vcard unless we added some other placeholder argument that forces the filename to arg2.

Other commands in the repl have the same limitation, like sendhtml, so without major changes, we probably just have to live with only handling "nice" filenames. (And if it ever is revised, then we hope nobody complains that we broke the syntax for sending a file whose name is a single backslash, the "xkcd 1172" effect.)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, of course supporting spaces in filenames should be implemented for all commands then, so better not in this PR. Breaking support for "\" as a filename is fine, in favor of "\\". For now let's wait a bit for other reviewers, if any, and merge this.

@iequidoo iequidoo merged commit 4a1a212 into chatmail:main Jul 30, 2025
22 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support addition of key contacts by vCard in repl
2 participants